//
//  MineRechargeCompleteViewController.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/9/4.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "MineRechargeCompleteViewController.h"

@interface MineRechargeCompleteViewController ()

@end

@implementation MineRechargeCompleteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addBackItem];
    self.title = @"充值完成";
    
    UILabel *priceLabel = [UILabel new];
    priceLabel.text = @"150";
    priceLabel.textColor = ColorFrom16(0xF5CB37);
    priceLabel.font = [UIFont fontWithName:@"Avenir-Book" size:48];
    priceLabel.textAlignment = 1;
    [self.view addSubview:priceLabel];
    [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(55 );
        make.centerX.equalTo(self.view.mas_centerX);
        make.width.greaterThanOrEqualTo(@80);
        make.height.equalTo(@55);
    }];
    
    UILabel *reminderLabel = [UILabel new];
    reminderLabel.text = @"(￥)派乐宝当前余额";
    reminderLabel.textColor = ColorFrom16(0x999999);
    reminderLabel.font = PFRFONT(14);
    reminderLabel.attributedText = [GW_Tool setTextColor:ColorFrom16(0xF5CB37) rangeOfString:@"(￥)" string:reminderLabel.text textFont:12];
    [self.view addSubview:reminderLabel];
    [reminderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(priceLabel.mas_bottom).offset(19);
        make.centerX.equalTo(self.view.mas_centerX);
        make.width.greaterThanOrEqualTo(@104);
        make.height.equalTo(@20);
    }];
    
    UIButton *rechargeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rechargeBtn setTitle:@"继续充值" forState:0];
    [rechargeBtn setTitleColor:ColorFrom16(0x202020) forState:0];
    rechargeBtn.titleLabel.font = PFRFONT(16);
    rechargeBtn.layer.backgroundColor = ColorFrom16(0xFEDE6D).CGColor;
    rechargeBtn.layer.cornerRadius = 7;
    [rechargeBtn addTarget:self action:@selector(actionRecharge) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:rechargeBtn];
    [rechargeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(reminderLabel.mas_bottom).offset(37);
        make.left.equalTo(self.view).offset(20);
        make.right.equalTo(self.view).offset(-20);
        make.height.equalTo(@44);
    }];
    
    
    [NetWork sendPostRequestURL:[NSString stringWithFormat:@"%@/common/getUserInfo", GW_Domain] parameters:nil completionBlockWithSuccess:^(NSDictionary *resultDict) {
//        NSLog(@"用户信息 %@", resultDict);
        NSDictionary *dict = resultDict[@"data"];
        [[NSUserDefaults standardUserDefaults] setObject:STRING(dict[@"balance"]) forKey:kUDBalance];
        priceLabel.text = STRING(dict[@"balance"]);
    } andFailure:^(NSError *error, NSString *errorMsg) {
        NSLog(@"%@", error);
    }];
}

- (void)actionRecharge
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
